package com.bjpowernode.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice(basePackages = "com.bjpowernode.controller")
public class GlobalExceptionHandler {

    @ExceptionHandler(value = GlobalException.class)
    @ResponseBody
    public ExceptionResult exceptionHandler(GlobalException e){
        return ExceptionResult.error(1,e.getMessage());
    }

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ExceptionResult otherExceptionHandler(Exception e){
        return ExceptionResult.error(1,"系统繁忙");
    }
}
